function process_show_2d(mesh)
figure;
plot_node_elem_2d(mesh.node(1:mesh.Np,:), mesh.elem(:,1:3));
hold on
if mesh.basis_type == "P1b" || mesh.basis_type == "P2"
    plot(mesh.node(mesh.Np+1:end,1), mesh.node(mesh.Np+1:end,2), 'k.', 'MarkerSize', 15);
    text(mesh.node(mesh.Np+1:end,1)+0.015, mesh.node(mesh.Np+1:end,2)+0.015, int2str((mesh.Np+1:mesh.Nb)'), 'FontSize', 12, 'FontWeight', 'bold', 'Color', 'k');
end
hold off
end

%% plot_node_elem_2d
function plot_node_elem_2d(node, elem)
showmesh(node, elem);
findnode(node);
findelem(node, elem);
end

%% showmesh
function showmesh(node, elem)
h = patch('Faces', elem, 'Vertices', node);
set(h, 'facecolor', 'w', 'edgecolor', 'k');
axis equal;
axis tight;
end

%% findnode
function findnode(node)
hold on
range = (1:size(node,1))';
plot(node(range,1), node(range,2), 'k.', 'MarkerSize', 15);
text(node(range,1)+0.015, node(range,2)+0.015, int2str(range), 'FontSize', 12, 'FontWeight', 'bold', 'Color', 'k');
hold off
end

%% findelem
function findelem(node, elem)
hold on
range = (1:size(elem,1))';
center = zeros(size(elem,1),2);
for i = 1:size(elem,1)
    V = node(elem(i,:),:);
    center(i,:) = polygon_centroid(V);
end
text(center(:,1), center(:,2), int2str(range), 'FontSize', 12, 'FontWeight', 'bold', 'Color', 'r');
hold off
end

%% polygon_centroid
function center = polygon_centroid(V)
n = size(V,1);
A = 0;
center_x = 0;
center_y = 0;
for i = 1:n
    j = mod(i,n) + 1;
    xi = V(i,1);
    yi = V(i,2);
    xj = V(j,1);
    yj = V(j,2);
    factor = xi * yj - xj * yi;
    A = A + factor;
    center_x = center_x + (xi + xj) * factor;
    center_y = center_y + (yi + yj) * factor;
end
center_x = center_x / (3 * A);
center_y = center_y / (3 * A);
center = [center_x, center_y];
end